MaxSize = 100


# 定义栈

class Stack:
    def __init__(self, n=MaxSize):
        self.elem = [0] * n
        self.top = -1

    def push(self, e):
        if self.top == MaxSize - 1:  # 栈满不进
            return False
        self.top += 1
        self.elem[self.top] = e
        return True

    def pop(self):
        if self.top == -1:  # 栈空不出
            return False
        self.top -= 1
        return True

    def getTop(self):
        return self.elem[self.top]

    def empty(self):  # 判断栈是否为空
        return self.top == -1


# 判断括号是否匹配的算法
def check(a):
    s = Stack()
    n = len(a)
    state = True
    for i in range(n):
        if a[i] == '(' or a[i] == '[':
            s.push(a[i])
        elif not s.empty() and s.getTop() == '(' and a[i] == ')':
            s.pop()
        elif not s.empty() and s.getTop() == '[' and a[i] == ']':
            s.pop()
        else:
            state = False
            break
    return s.empty() and state


print('yes'if check('(((([[]]))))')else'no')
print('yes'if check('((((]]))))')else'no')
